/*
 * Copyright 2011 Sebastian Maurer
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 * http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package erepublik.dto;

import java.util.Calendar;
import java.util.List;

import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlElementWrapper;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;

@XmlRootElement
@XmlAccessorType(XmlAccessType.FIELD)
public class War extends IDType {

	@XmlElement(name="active-battle-count")
	private Integer activeBattleCount;
	
	@XmlJavaTypeAdapter(value=IntegerAdapter.class)
	@XmlElementWrapper(name="battles")
	@XmlElement(name="battle")
	private List<Integer> battles;
	
	@XmlElement(name="proclaimed-by")
	private Proclaimed proclaimedBy;
	
	@XmlElement(name="proclaimed-to")
	private Proclaimed proclaimedTo;
	
	private Progress progress = new Progress();
	
	@XmlElement(name="is-resistance")
	private Boolean resistance;

	public Integer getActiveBattleCount() {
		return activeBattleCount;
	}

	public List<Integer> getBattles() {
		return battles;
	}

	public Proclaimed getProclaimedBy() {
		return proclaimedBy;
	}

	public Proclaimed getProclaimedTo() {
		return proclaimedTo;
	}

	public Boolean getResistance() {
		return resistance;
	}

	public void setActiveBattleCount(Integer activeBattleCount) {
		this.activeBattleCount = activeBattleCount;
	}

	public void setBattles(List<Integer> battles) {
		this.battles = battles;
	}

	public void setProclaimedBy(Proclaimed proclaimedBy) {
		this.proclaimedBy = proclaimedBy;
	}

	public void setProclaimedTo(Proclaimed proclaimedTo) {
		this.proclaimedTo = proclaimedTo;
	}

	public void setResistance(Boolean resistance) {
		this.resistance = resistance;
	}

	public Calendar getFinishedAt() {
		return progress.finishedAt;
	}

	public String getFinishedReason() {
		return progress.finishedReason;
	}

	public Calendar getStartedAt() {
		return progress.startedAt;
	}

	public void setFinishedAt(Calendar finishedAt) {
		this.progress.finishedAt = finishedAt;
	}

	public void setFinishedReason(String finishedReason) {
		this.progress.finishedReason = finishedReason;
	}

	public void setStartedAt(Calendar startedAt) {
		this.progress.startedAt = startedAt;
	}
	
	@XmlType(name="WarProgress")
	@XmlAccessorType(XmlAccessType.FIELD)
	private static class Progress {
		
		@XmlElement(name="finished-at")
		private Calendar finishedAt;
		
		@XmlElement(name="finished-reason")
		private String finishedReason;
		
		@XmlElement(name="started-at")
		private Calendar startedAt;

	}
	
}
